/*
 * biosignalfilereader.h
 *
 *  Created on: Aug 25, 2009
 *      Author: zaca
 */

#ifndef BIOSIGNALFILEREADER_H_
#define BIOSIGNALFILEREADER_H_

#include <string>
#include <list>

namespace biosignal
{
class BioSignal;

class Reader
{
protected:
	std::string name_;
public:
	virtual bool can_read( std::string file_name ) = 0;
	virtual std::string filterString() = 0;
	virtual const BioSignal* read( std::string file_name ) = 0;
	std::string name() {return name_; };
};

template<class T>
Reader* reader_factory()
{
    return new T;
}

typedef Reader* (*reader_creator)(void);


class ReaderRegistry
{
private:
	std::list<reader_creator> m_readers;
public:
    typedef std::list<reader_creator>::iterator iterator;
    static ReaderRegistry& get();
    void add(reader_creator);
    iterator begin();
    iterator end();

    const BioSignal* load( std::string file_name );
};

class ReaderRegistration
{
    public:
		ReaderRegistration(reader_creator);
};

#define AUTO_REGISTER_READER(reader) ReaderRegistration _reader_registration_ ## reader(&reader_factory<reader>);

}
#endif /* BIOSIGNALFILEREADER_H_ */
